# Maintainer: Ariadne Conill <ariadne@dereferenced.org>
pkgname=ko
pkgver=0.15.2
pkgrel=1
pkgdesc="Build containers from Go projects"
url="https://ko.build/"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/ko-build/ko/archive/v$pkgver/ko-$pkgver.tar.gz
	unset-CGO_ENABLED.patch
	"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -ldflags "-X github.com/google/ko/pkg/commands.Version=$pkgver"

	for i in bash fish zsh; do
		./ko completion $i > ko.$i
	done
}

check() {
	# TestNewPublisherCanPublish test tries to connect to the Docker socket.
	go test -skip TestNewPublisherCanPublish ./...
}

package() {
	install -Dm755 ko -t "$pkgdir"/usr/bin/

	install -Dm644 ko.bash "$pkgdir"/usr/share/bash-completion/completions/ko
	install -Dm644 ko.fish "$pkgdir"/usr/share/fish/vendor_completions.d/ko.fish
	install -Dm644 ko.zsh "$pkgdir"/usr/share/zsh/site-functions/_ko
}

sha512sums="
3beee6f1540a2badf9f98a6b7a08800e4c49c58cc8d3fede20d309d0b06be1ab8d43f495a96e33c3d4ac319fed402bccfee197f07420c58e37759ffe3ea04c40  ko-0.15.2.tar.gz
d9d8106872ce929f340978a4ff78c588a3ea7cb135a89669e7900b9568586b753a38a2b0cbfdf0e9610d9fdc2d1bed2f7027132263a926fdc9ef1a6b3fe36bd4  unset-CGO_ENABLED.patch
"
